package com.qf.im.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qf.im.entity.FriendRequest;
import com.qf.im.entity.vo.RequestInfoVo;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 好友申请表(FriendRequest)表数据库访问层
 *
 * @author makejava
 * @since 2023-10-30 14:17:04
 */
public interface FriendRequestDao extends BaseMapper<FriendRequest> {

    /**
     * 根据我的ID 查询所有发送给我的好友申请
     * @param uid
     * @return
     */
    @Select("""
        select fr.id, u.header, u.nickname, u.username, fr.info, fr.create_time, fr.status 
            from friend_request fr join user u
            on fr.req_id = u.id
            where fr.to_id = #{uid} order by fr.create_time desc;
    """)
    List<RequestInfoVo> queryRequestInfo(Integer uid);
}

